package com.corpgovernment.common.enums;

import com.google.common.collect.Lists;

import java.util.List;

/**
 * @auth:yaqiangzhang
 * @date:2020/1/7 16:48
 */
public enum YOrCFClazzEnum {
    /**
     * 经济舱
     */
    Y("Y", "经济舱"),
    /**
     * 公务舱
     */
    CF("C,F", "公务/头等舱");

    private String code;

    private String name;

    YOrCFClazzEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    /**
     * 根据code转换枚举
     */
    public static YOrCFClazzEnum getEnumByCode(String code) {
        YOrCFClazzEnum result = null;
        for (YOrCFClazzEnum item : YOrCFClazzEnum.values()) {
            if (item.getCode().equalsIgnoreCase(code)) {
                result = item;
                break;
            }
        }
        return result;
    }

    public static List<String> getAllCodes(){
        List<String> result = Lists.newArrayList();
        for (ClazzEnum item : ClazzEnum.values()) {
            result.add(item.getCode());
        }
        return result;
    }
}
